Hello Everyone,
I have been facing a problem since last night, actually i want to import data from excel to datatable in C#.Net. So please resolve my problem as soon as possible.
Thanks in advance!!
Home / DeveloperSection / Forums / How to import data from excel to datatable in c#
Hello Everyone,
I have been facing a problem since last night, actually i want to import data from excel to datatable in C#.Net. So please resolve my problem as soon as possible.
Thanks in advance!!
lethl marc
19-Oct-2014MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\yourfile.xls';Extended Properties=Excel 8.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
MyCommand.TableMappings.Add("Table", "TestTable");
DtSet = new System.Data.DataSet();
MyCommand.Fill(DtSet);
Lethal
Sebastien Morin
19-Feb-2014anver sadat
08-Apr-2013thnx for sharing your code, it saved my lots of time.i was getting error when application was deployed on server.
htnx
Laila prog
21-Mar-2013I want to import data from an Excel file into a database SQL Server 2008, the Excel file contains multiple sheets, each sheet represents a table row e in the database, and I must also respect the constraints intergrités, if you can offer me a code that does almost the same thing THANKS
Anonymous User
10-Jan-2012Hello Pravesh Singh,
Check this code...
It might be resolve your problem.